package com.zd.web.servlet;

import java.io.IOException;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.zd.service.impl.*;
import com.zd.service.*;
/**
 * Servlet implementation class AddChapterServlet
 */
@WebServlet("/AddChapterServlet")
public class AddChapterServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
   
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		String chapterName=request.getParameter("chapterName");
		int novelId=Integer.parseInt(request.getParameter("novelId"));
		String text=request.getParameter("chapterContent");
		AdminChapterService acs=new AdminChapterServiceImpl();
		Date date = new Date(System.currentTimeMillis());
		int num=acs.addChapter(chapterName,novelId,text,date);
		System.out.println(num+"添加成功");
		response.sendRedirect("chapter.jsp");
	}

}
